source_registry="harbor.aliyun-hd1.logan.xiaopeng.inner"                               # 源仓库
goal_registry="hd1-k8s-test-harbor-registry-vpc.cn-hangzhou.cr.aliyuncs.com"           # 目标仓库 
harbor_image=$(grep -v '^\s*$' ./images.txt | grep -v '^#')




######### 判断images.txt文件#########
if [ -f "./images.txt" ];then
    :
else
    echo -e "\nERROR: Please create a file named images.txt, which should be located in the same directory as the images.sh script. The purpose of this file is to write the required image names into it. Subsequently, the images.sh script will read this file and perform the image pull operations based on the image names listed therein.\n"
exit
fi

if [ $(grep -v '^\s*$' ./images.txt | grep -v '^#' |wc -l) -eq 0 ];then
    echo "The images.text file does not specify the image."
    exit
else
    :


fi


##########判断结束#########################




for pull_image in $harbor_image;do


crane copy --insecure   $source_registry/$pull_image   $goal_registry/$pull_image

	sed -i "s|$pull_image|#$pull_image|" images.txt

done

